// pages/distributor/searchVisitor/searchVisitor.js
// pages/main/others/touristsearch.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    date1: '',
    show1: false,
    minDate1: new Date(2024, 0, 1).getTime(),
    maxDate1: new Date(2025, 0, 31).getTime(),
    date2: '',
    show2: false,
    minDate2: new Date(2024, 0, 1).getTime(),
    maxDate2: new Date(2025, 0, 31).getTime(),
    ordercode:'',
    travelName:'',
    name:'',
    tel:'',
    idcode:'',
    searchinfo:{}
  },
  //订单编号
  getordercode(event){
    this.setData({
      ordercode:event.detail.value
    })
  },
  //旅行名称
  getproductcode(event){
    this.setData({
      travelName:event.detail.value
    })
  },
  //游客姓名
  gettouristname(event){
    this.setData({
      name:event.detail.value
    })
  },
  //游客电话
  gettouristtel(event){
    this.setData({
      tel:event.detail.value
    })
    console.log("dianhuahao",this.data.tel);
  },
  //证件号码
  gettouristidcode(event){
    this.setData({
      idcode:event.detail.value
    })
  },
  //去游客列表
  gotourlist(){
    this.setData({
      searchinfo:{
        orderNum:this.data.ordercode,
        idCard:this.data.idcode,
        tel:this.data.tel,
        travelName:this.data.travelName,
        beginTime:this.data.date1,
        endTime:this.data.date2,
        name:this.data.name,
      }
     })
    let search={}
    for(var i in this.data.searchinfo){
      console.log(this.data.searchinfo[i]);
      if(this.data.searchinfo[i] || this.data.searchinfo[i]!=0){
        search[i]=this.data.searchinfo[i]
      }
    }
    console.log("searchdata",this.data.searchinfo);
    console.log("search",search);
    wx.setStorageSync('searchinfo', JSON.stringify(search))
    wx.navigateTo({
      url: '../myVisitor/myVisitor',
    })
  },
  onDisplay1() {
    this.setData({ show1: true });
  },
  onClose1() {
    this.setData({ show1: false });
  },
  onConfirm1(event) {
    console.log(11111);
    this.setData({
      show1: false,
      date1: this.formatDate(event.detail),
    });
  },
  formatDate(date) {
    date = new Date(date);
    console.log(date.getFullYear());
    return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
  },


  onDisplay2() {
    this.setData({ show2: true });
  },
  onClose2() {
    this.setData({ show2: false });
  },
  
  onConfirm2(event) {
    console.log(11111);
    this.setData({
      show2: false,
      date2: this.formatDate(event.detail),
    });
  },
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})